home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Src / MTAconsole / data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  16.9 KB  |  747 lines

  1. /* data.c: routines to deal with data structures */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Src/MTAconsole/RCS/data.c,v 6.0 1991/12/18 20:26:48 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Src/MTAconsole/RCS/data.c,v 6.0 1991/12/18 20:26:48 jpo Rel $
  9.  *
  10.  * $Log: data.c,v $
  11.  * Revision 6.0  1991/12/18  20:26:48  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include    "console.h"
  19. #include    "Qmgr-types.h"
  20.  
  21. extern time_t        convert_time();
  22. struct chan_struct    *find_channel();
  23. struct mta_struct    *find_mta();
  24. struct procStatus    *create_status();
  25. void            update_status();
  26. /*   */
  27. /* channel */
  28. static void create_channel_list();
  29. static void update_channel_list();
  30. static struct chan_struct *create_channel();
  31. static void update_channel();
  32.  
  33. struct monitor_item    **display_list = NULL;
  34. struct chan_struct    **globallist = NULL,
  35.             **ordered_list = NULL,
  36.             *currentchan = NULL;
  37. int            num_channels,
  38.             read_currentchan = 0;
  39. int            firstChanRead;
  40. int            total_number_messages,
  41.             total_number_reports,
  42.             total_volume,
  43.             delta_volume,
  44.             delta_messages,
  45.             delta_reports;
  46. extern int        forceDown;
  47. extern int        uk_order;
  48. extern int        compat;
  49.  
  50. channel_list(new)
  51. struct type_Qmgr_PrioritisedChannelList *new;
  52. {
  53.     if (compat) {
  54.         total_number_messages = 0;
  55.         total_number_reports = 0;
  56.         total_volume = 0;
  57.     }
  58.     if (globallist == NULL) {
  59.         create_channel_list(new);
  60.         firstChanRead = TRUE;
  61.     } else {
  62.         update_channel_list(new);
  63.         firstChanRead = FALSE;
  64.     }
  65. }
  66.  
  67. static int chantype_compare(one, two)
  68. struct chan_struct    **one,
  69.             **two;
  70. {
  71.     register int    onetype, twotype;
  72.     
  73.     onetype = (*one)->chantype;
  74.     twotype = (*two)->chantype;
  75.  
  76.     if (onetype != twotype) {
  77.         if (onetype == int_Qmgr_chantype_mta)
  78.             return -1;
  79.         if (twotype == int_Qmgr_chantype_mta)
  80.             return 1;
  81.         if (onetype == int_Qmgr_chantype_mts)
  82.             return -1;
  83.         if (twotype == int_Qmgr_chantype_mts)
  84.             return 1;
  85.         if (onetype == int_Qmgr_chantype_internal)
  86.             return -1;
  87.         if (twotype == int_Qmgr_chantype_internal)
  88.             return 1;
  89.     } 
  90.  
  91.     /* order on inbound and outbound */
  92.     if ((*one)->inbound == (*two)->inbound
  93.         && (*one)->outbound == (*two) -> outbound)
  94.         return 0;
  95.     if ((*one)->outbound > (*two) -> outbound)
  96.         return -1;
  97.     if ((*one)->outbound < (*two)->outbound)
  98.         return 1;
  99.     if ((*one)->inbound > (*two) -> inbound)
  100.         return -1;
  101.     if ((*one)->inbound < (*two)->inbound)
  102.         return 1;
  103.     return 0;
  104. }
  105.  
  106. static void    create_channel_list(list)
  107. struct type_Qmgr_PrioritisedChannelList    *list;
  108. /* calloc and fillin in globallist */
  109. {
  110.     struct type_Qmgr_PrioritisedChannelList    *ix = list;
  111.     int    i,
  112.         num = 0;
  113.  
  114.     while (ix != NULL) {
  115.         num++;
  116.  
  117.         ix = ix->next;
  118.     }
  119.  
  120.     num_channels = num;
  121.     globallist = (struct chan_struct **) calloc((unsigned) num, 
  122.                              sizeof(struct chan_struct *));
  123.     ordered_list = (struct chan_struct **) calloc((unsigned) num, 
  124.                               sizeof(struct chan_struct *));
  125.     display_list = (struct monitor_item **) calloc((unsigned) num, 
  126.                                sizeof(struct monitor_item *));
  127.     resize_chan_array(num);
  128.     
  129.     ix = list;
  130.     i = 0;
  131.     while ((ix != NULL) 
  132.            && (i < num)) {
  133.         globallist[i] = create_channel(ix);
  134.         i++;
  135.         ix = ix->next;
  136.     }
  137.     
  138.     qsort((char *) &(globallist[0]), num,
  139.           sizeof(globallist[0]), (IFP)chantype_compare);
  140.  
  141.     i = 0;
  142.     while (i < num) {
  143.         ordered_list[i] = globallist[i];
  144.         display_list[i] = (struct monitor_item *) calloc(1, sizeof(struct monitor_item));
  145.         display_list[i]->channel = &(ordered_list[i]);
  146.         i++;
  147.     }
  148. }
  149.  
  150. extern time_t    boottime;
  151.  
  152. static struct chan_struct    *create_channel(chan)
  153. struct type_Qmgr_PrioritisedChannelList *chan;
  154. {
  155.     struct chan_struct        *temp;
  156.     struct type_Qmgr_ChannelInfo    *info;
  157.  
  158.     temp = (struct chan_struct *) calloc(1, sizeof(*temp));
  159.     info = chan->PrioritisedChannel->channel;
  160.     
  161.     temp->channelname = qb2str(info->channel);
  162.     temp->channeldescrip = qb2str(info->channelDescription);
  163.  
  164.     temp->oldestMessage = convert_time(info->oldestMessage); 
  165.     temp->numberMessages = info->numberMessages;
  166.     temp->numberReports = info->numberReports;
  167.     temp->volumeMessages = info->volumeMessages;
  168.     temp->given_num_mtas = info->numberMtas;
  169.     if (compat) {
  170.         total_volume += temp->volumeMessages;
  171.         total_number_reports += temp->numberReports;
  172.         total_number_messages += temp->numberMessages;
  173.     }
  174.     temp->numberActiveProcesses = info->numberActiveProcesses;
  175.     temp->status = create_status(info->status);
  176.     if (temp->status->lastSuccess == 0)
  177.         temp->status->lastSuccess = boottime;
  178.     temp->priority = chan->PrioritisedChannel->priority->parm;
  179.     temp->inbound = bit_test(info->direction, bit_Qmgr_direction_inbound);
  180.     temp->outbound = bit_test(info->direction, bit_Qmgr_direction_outbound);
  181.     temp->chantype = info->chantype;
  182.     temp->maxprocs = info->maxprocs;
  183.  
  184.     add_tailor_to_chan(temp);
  185.     return temp;
  186. }
  187.  
  188. static void    update_channel_list(new)
  189. struct type_Qmgr_PrioritisedChannelList    *new;
  190. {
  191.     struct type_Qmgr_PrioritisedChannelList *ix = new;
  192.     char                    *name = NULL;
  193.     struct chan_struct            *chan;
  194.  
  195.     while (ix != NULL) {
  196.         if (name != NULL) free(name);
  197.         name = qb2str(ix->PrioritisedChannel->channel->channel);
  198.  
  199.         chan = find_channel(name);
  200.         if (chan == NULL) {
  201.             PP_LOG(LLOG_EXCEPTIONS,
  202.                    ("console: can not find channel %s",name));
  203.             abort();
  204.         }
  205.         update_channel(chan,ix);
  206.         ix = ix->next;
  207.     }
  208. }
  209.  
  210. static void    update_channel(old, new)
  211. struct chan_struct            *old;
  212. struct type_Qmgr_PrioritisedChannelList    *new;
  213. {
  214.     struct type_Qmgr_ChannelInfo    *info;
  215.  
  216.     info = new->PrioritisedChannel->channel;
  217.     /* name and description don't change */
  218.     old->oldestMessage = convert_time(info->oldestMessage);
  219.     old->deltaMessages = info->numberMessages - old->numberMessages;
  220.     old->numberMessages = info->numberMessages;
  221.     old->deltaReports = info->numberReports - old->numberReports;
  222.     old->numberReports = info->numberReports;
  223.     old->deltaVolume = info->volumeMessages-old->volumeMessages;
  224.     old->volumeMessages = info->volumeMessages;
  225.     old->deltaMtas = info->numberMtas - old->given_num_mtas;
  226.     old->given_num_mtas = info->numberMtas;
  227.     if (compat) {
  228.         total_volume += old->volumeMessages;
  229.         total_number_reports += old->numberReports;
  230.         total_number_messages += old->numberMessages;
  231.     }
  232.     old->numberActiveProcesses = info->numberActiveProcesses;
  233.     update_status(old->status,info->status);
  234.     old->priority = new->PrioritisedChannel->priority->parm;
  235.     old->maxprocs = info->maxprocs;
  236. }
  237.  
  238. free_channel_list()
  239. {
  240.     int    i =0;
  241.     if (globallist == NULL)
  242.         return;
  243.     while (i < num_channels) {
  244.         free(globallist[i]->channelname);
  245.         free(globallist[i]->channeldescrip);
  246.         free ((char *)globallist[i]->status);
  247.         if (globallist[i]->mtalist != NULL)
  248.             free_mta_list(&(globallist[i]->mtalist),
  249.                       &(globallist[i]->num_mtas));
  250.         i++;
  251.     }
  252.     free((char *) globallist);
  253.     free((char *) ordered_list);
  254.     ordered_list = NULL;
  255.     globallist = NULL;
  256. }
  257.  
  258. struct chan_struct *find_channel(name)
  259. char            *name;
  260. {
  261.     int    i = 0;
  262.     while ((i < num_channels) && 
  263.            (lexequ(globallist[i]->channelname, name) != 0)) 
  264.         i++;
  265.  
  266.     if (i >= num_channels) 
  267.         return NULL;
  268.     else
  269.         return globallist[i];
  270. }
  271.  
  272. /*   */
  273. /* mtas */
  274. static void update_mta_list();
  275. static struct mta_struct **create_mta_list();
  276. static struct mta_struct *create_mta();
  277.  
  278. struct mta_struct    *currentmta = NULL;
  279. int            read_currentmta = 0;
  280.  
  281. struct chan_struct *mta_list(new, channame)
  282. struct type_Qmgr_PrioritisedMtaList    *new;
  283. char                    *channame;
  284. {
  285.     struct chan_struct            *chan;
  286.  
  287.     if (channame == NULLCP) {
  288.         PP_LOG(LLOG_EXCEPTIONS,
  289.                ("console: mta_list no channel name given"));
  290.         abort();
  291.     }
  292.  
  293.     chan = find_channel(channame);
  294.     if (chan == NULL) {
  295.         PP_LOG(LLOG_EXCEPTIONS,
  296.                ("console: can not find channel %s", channame));
  297.         abort();
  298.     }
  299.  
  300.     free_mta_list(&(chan->mtalist), &(chan->num_mtas));
  301.     chan->mtalist = NULL;
  302.     chan->num_mtas = 0;
  303.     if (new != NULL)
  304.         update_mta_list(new, chan);
  305.     else
  306.         update_channel_from_mtas(chan, 0, 0, 0, 0);
  307.     return chan;
  308. }
  309.  
  310. static void update_mta_list(new, chan)
  311. struct type_Qmgr_PrioritisedMtaList    *new;
  312. struct chan_struct            *chan;
  313. {
  314.     int                    numberMsgs = 0,
  315.                         numberDrs = 0,
  316.                         numberMtas = 0,
  317.                         volume = 0;
  318.     chan->mtalist = create_mta_list(new,&numberMtas,
  319.                     &numberDrs,&numberMsgs,&volume,
  320.                     chan);
  321.     update_channel_from_mtas(chan, numberMsgs, numberDrs, numberMtas, volume);
  322. }
  323.  
  324. static struct mta_struct    **create_mta_list(list, pnum, pdr, pmsgnum, pvolume, chan)
  325. struct type_Qmgr_PrioritisedMtaList    *list;
  326. int                    *pnum,
  327.                       *pdr,
  328.                     *pmsgnum,
  329.                     *pvolume;
  330. struct chan_struct            *chan;
  331. {
  332.     struct type_Qmgr_PrioritisedMtaList     *ix = list;
  333.     struct mta_struct            **mtalist;
  334.     int                    i;
  335.     while (ix != NULL) {
  336.         (*pnum)++;
  337.  
  338.         ix = ix->next;
  339.     }
  340.     
  341.     mtalist = (struct mta_struct    **) calloc( (unsigned)(*pnum), 
  342.                            sizeof(struct mta_struct *));
  343.  
  344.     ix = list;
  345.     i = 0;
  346.     *pmsgnum = 0;
  347.     *pdr = 0;
  348.  
  349.     while ((ix != NULL)
  350.            && ( i < (*pnum))) {
  351.         mtalist[i] = create_mta(ix->PrioritisedMta, chan);
  352.         *pmsgnum += mtalist[i]->numberMessages;
  353.         *pdr += mtalist[i]->numberReports;
  354.         *pvolume += mtalist[i]->volumeMessages;
  355.         i++;
  356.         ix = ix->next;
  357.     }
  358.     return mtalist;
  359. }
  360.  
  361. static struct mta_struct    *create_mta(mta, chan)
  362. struct type_Qmgr_PrioritisedMta    *mta;
  363. struct chan_struct        *chan;
  364. {
  365.     struct mta_struct        *temp;
  366.     struct type_Qmgr_MtaInfo    *info = mta->mta;
  367.  
  368.     temp = (struct mta_struct *) malloc(sizeof(*temp));
  369.  
  370.     temp->mta = qb2str(info->mta);
  371.     temp->oldestMessage = convert_time(info->oldestMessage);
  372.     temp->numberMessages = info->numberMessage;
  373.     temp->numberReports = info->numberDRs;
  374.     temp->volumeMessages = info->volumeMessages;
  375.     temp->status = create_status(info->status);
  376.     temp->priority = mta->priority->parm;
  377.     temp->active = info->active;
  378.     if (info -> info != NULL)
  379.         temp -> info = qb2str(info -> info);
  380.     else
  381.         temp -> info = NULLCP;
  382.     add_tailor_to_mta(chan, temp);
  383.     if (forceDown == TRUE)
  384.         MtaDownForce(chan, temp);
  385.     return temp;
  386. }
  387.  
  388. update_mta(old, info)
  389. struct mta_struct            *old;
  390. struct type_Qmgr_MtaInfo        *info;
  391. {
  392.     /* name doesn't change */
  393.     old->oldestMessage = convert_time(info->oldestMessage);
  394.     old->numberMessages = info->numberMessage;
  395.     old->numberReports = info->numberDRs;
  396.     old->volumeMessages = info->volumeMessages;
  397.     old->active = info->active;
  398.     if (old -> info) 
  399.         free (old -> info);
  400.     if (info -> info != NULL)
  401.         old -> info = qb2str(info -> info);
  402.     else
  403.         old -> info = NULLCP;
  404.     update_status(old->status,info->status);
  405. }
  406.  
  407. /* ordering routines */    
  408. struct mta_struct    *find_mta(chan, name)
  409. struct chan_struct    *chan;
  410. char            *name;
  411. {
  412.     int    i = 0;
  413.     while ((i < chan->num_mtas) &&
  414.            (strcmp(chan->mtalist[i]->mta, name) != 0))
  415.         i++;
  416.     if (i >= chan->num_mtas)
  417.         return NULL;
  418.     else
  419.         return chan->mtalist[i];
  420. }    
  421.  
  422. /* garbage collection routine */
  423.  
  424. free_mta_list(plist, pnum)
  425. struct mta_struct    ***plist;
  426. int            *pnum;
  427. {
  428.     int    i = 0;
  429.  
  430.     while(i < (*pnum)){
  431.         if ((*plist) [i] != NULL) {
  432.             free((*plist)[i]->mta);
  433.             if ((*plist)[i]->info != NULLCP)
  434.                 free((*plist)[i] -> info);
  435.             free((char *) (*plist)[i]->status);
  436.         }
  437.         i++;
  438.     }
  439.     if (*plist != NULL)
  440.         free((char *) (*plist));
  441.     *plist = NULL;
  442.     *pnum = 0;
  443. }
  444.  
  445. /*   */
  446. /* msgs */
  447. struct msg_struct    **global_msg_list = NULL,
  448.             *currentmsg = NULL;
  449. int            number_msgs = 0;
  450. static struct msg_struct    **create_msg_list();
  451.  
  452. msg_list(new)
  453. struct type_Qmgr_MsgList    *new;
  454. {
  455.     free_msg_list();
  456.     global_msg_list = create_msg_list(new->msgs);
  457. }
  458.  
  459.  
  460. static char    *create_eits(eit)
  461. struct type_Qmgr_EncodedInformationTypes    *eit;
  462. {
  463.     struct type_Qmgr_EncodedInformationTypes *ix;
  464.     char    *str,
  465.         buf[BUFSIZ];
  466.     int    first;
  467.     if (eit == NULL)
  468.         return NULL;
  469.     ix =eit;
  470.     first = True;
  471.  
  472.     while (ix != NULL) {
  473.         str = qb2str(ix->PrintableString);
  474.         if (first == True) {
  475.             sprintf(buf,"%s",str);
  476.             first = False;
  477.         } else 
  478.             sprintf(buf,"%s, %s",buf, str);
  479.         free(str);
  480.         ix = ix->next;
  481.     }
  482.     return strdup(buf);
  483. }
  484.  
  485. static struct permsginfo    *create_msginfo(info)
  486. struct type_Qmgr_PerMessageInfo    *info;
  487. {
  488.     struct permsginfo    *temp;
  489.  
  490.     temp = (struct permsginfo *) calloc(1,sizeof(*temp));
  491.  
  492.     temp->queueid = qb2str(info->queueid);
  493.     temp -> originator = qb2str(info->originator);
  494.     if (info->contenttype != NULL)
  495.         temp->contenttype = qb2str(info->contenttype);
  496.     else
  497.         temp->contenttype = NULL;
  498.     temp->eit = create_eits(info->eit);
  499.     temp->age = convert_time(info->age);
  500.     temp->size = info->size;
  501.     temp->priority = info->priority->parm;
  502.     if (info->expiryTime == NULL)
  503.         temp->expiryTime = 0;
  504.     else
  505.         temp->expiryTime = convert_time(info->expiryTime);
  506.     if (info->deferredTime == NULL)
  507.         temp->deferredTime = 0;
  508.     else 
  509.         temp->deferredTime = convert_time(info->deferredTime);
  510.     if (info->optionals & opt_Qmgr_PerMessageInfo_errorCount)
  511.         temp->errorCount = info->errorCount;
  512.     if (info->inChannel != NULL)
  513.         temp->inChannel = qb2str(info->inChannel);
  514.     else
  515.         temp->inChannel = NULLCP;
  516.     if (info->uaContentId != NULL)
  517.         temp -> uaContentId = qb2str(info->uaContentId);
  518.     else
  519.         temp -> uaContentId = NULLCP;
  520.     return temp;
  521. }
  522.  
  523. static char            *create_chans(list, done, pfirst)
  524. struct type_Qmgr_ChannelList    *list;
  525. int                done;
  526. char                **pfirst;
  527. {
  528.     int    count;
  529.     char    buf[BUFSIZ],
  530.         *str;
  531.  
  532.     struct type_Qmgr_ChannelList    *ix;
  533.     count = 0;
  534.     ix = list;
  535.     while (count < done && ix != NULL) {
  536.         ix = ix->next;
  537.         count++;
  538.     }
  539.     if (ix == NULL)
  540.         /* all done waiting for delivery notifcation */
  541.         return NULL;
  542.  
  543.     str = qb2str(ix->Channel);
  544.     sprintf(buf,"%s",str);
  545.     free(str);
  546.     *pfirst = qb2str(ix->Channel);
  547.     ix = ix->next;
  548.  
  549.     while (ix != NULL) {
  550.         str = qb2str(ix->Channel);
  551.         sprintf(buf, "%s, %s",buf,str);
  552.         free(str);
  553.         ix = ix->next;
  554.     }
  555.     return strdup(buf);
  556. }
  557.     
  558. static struct recip        *create_recip(recip)
  559. struct type_Qmgr_RecipientInfo    *recip;
  560. {
  561.     struct recip    *temp;
  562.  
  563.     temp = (struct recip *) calloc(1,sizeof(*temp));
  564.  
  565.     temp->id = recip->id->parm;
  566.  
  567.     temp -> recipient = qb2str(recip->user);
  568.     temp->mta = qb2str(recip->mta);
  569.     temp->chansOutstanding = create_chans(recip->channelList,
  570.                           recip->channelsDone,
  571.                           &temp->actChan);
  572.     temp->status = create_status(recip->procStatus);
  573.     if (recip -> info != NULL)
  574.         temp -> info = qb2str (recip -> info);
  575.     return temp;
  576. }
  577.     
  578.     
  579. static struct recip         *create_reciplist(list)
  580. struct type_Qmgr_RecipientList    *list;
  581. {
  582.     struct recip    *head = NULL,
  583.             *tail = NULL,
  584.             *temp;
  585.  
  586.     while (list != NULL) {
  587.         if (list->RecipientInfo->id != 0) {
  588.             temp = create_recip(list->RecipientInfo);
  589.             if (head == NULL)
  590.                 tail = head = temp;
  591.             else {
  592.                 tail->next = temp;
  593.                 tail = temp;
  594.             }
  595.         }
  596.         list = list->next;
  597.     }
  598.     return head;
  599. }
  600.  
  601. static struct msg_struct    *create_msg(msg)
  602. struct type_Qmgr_MsgStruct    *msg;
  603. {
  604.     struct msg_struct    *temp;
  605.     
  606.     temp = (struct msg_struct *) calloc(1, sizeof(*temp));
  607.     temp->msginfo = create_msginfo(msg->messageinfo);
  608.     temp->reciplist = create_reciplist(msg->recipientlist);
  609.     add_tailor_to_msg(currentchan,temp);
  610.     if (forceDown == TRUE) 
  611.         MsgDownForce(temp);
  612.     return temp;
  613. }
  614.  
  615. static struct msg_struct    **create_msg_list(list)
  616. struct type_Qmgr_MsgStructList    *list;
  617. {
  618.     struct type_Qmgr_MsgStructList    *ix = list;
  619.     struct msg_struct        **msglist;
  620.     int                i;
  621.     number_msgs = 0;
  622.     while (ix != NULL) {
  623.         number_msgs++;
  624.         ix = ix->next;
  625.     }
  626.  
  627.     msglist = (struct msg_struct **) calloc((unsigned) number_msgs, 
  628.                         sizeof(struct msg_struct *));
  629.     
  630.     ix = list;
  631.     i = 0;
  632.     while ((ix != NULL)
  633.            & (i < number_msgs)) {
  634.         msglist[i] = create_msg(ix->MsgStruct);
  635.         i++;
  636.         ix = ix->next;
  637.     }
  638.     return msglist;
  639. }
  640.  
  641. free_msg_list()
  642. {
  643.     int i = 0;
  644.     if (global_msg_list == NULL || number_msgs == 0)
  645.         return;
  646.  
  647.     while (i < number_msgs) {
  648.         free_permsginfo(global_msg_list[i]->msginfo);
  649.         free_reciplist(global_msg_list[i]->reciplist);
  650.         i++;
  651.     }
  652.     free((char *) global_msg_list);
  653.     global_msg_list = NULL;
  654.     number_msgs = 0;
  655. }
  656.  
  657. free_permsginfo(info)
  658. struct permsginfo    *info;
  659. {
  660.     free(info->queueid);
  661.     free(info->originator);
  662.     if (info->eit != NULL) free(info->eit);
  663.     if (info->inChannel != NULL) free(info->inChannel);
  664.     if (info->uaContentId != NULLCP) free(info->uaContentId);
  665.     free((char *) info);
  666. }
  667.  
  668. free_reciplist(list)
  669. struct recip    *list;
  670. {
  671.     struct recip    *ix = list,
  672.             *temp;
  673.  
  674.     while (ix != NULL) {
  675.         if (ix->recipient) free(ix->recipient);
  676.         if (ix->mta != NULL) free(ix->mta);
  677.         if (ix->actChan != NULL) free(ix->actChan);
  678.         if (ix->chansOutstanding != NULL) free(ix->chansOutstanding);
  679.         if (ix -> info != NULL) free(ix->info);
  680.         free((char *) ix->status);
  681.         temp = ix;
  682.         ix = ix->next;
  683.         free((char *) temp);
  684.     }
  685. }
  686.  
  687.  
  688. struct recip    *find_recip(msg, id)
  689. struct msg_struct    *msg;
  690. int            id;
  691. {
  692.     struct recip    *ix;
  693.     if (msg == NULL)
  694.         return NULL;
  695.     ix = msg->reciplist;
  696.     
  697.     while (ix != NULL
  698.            && ix -> id != id)
  699.         ix = ix->next;
  700.     return ix;
  701. }
  702.  
  703. struct msg_struct *find_msg(qid)
  704. char    *qid;
  705. {
  706.     int    i = 0;
  707.  
  708.     while ((i < number_msgs) &&
  709.            (strcmp(global_msg_list[i]->msginfo->queueid,qid) != 0))
  710.         i++;
  711.     if (i >= number_msgs)
  712.         return NULL;
  713.     else
  714.         return global_msg_list[i];
  715. }
  716.  
  717. /*   */
  718. /* misc */
  719. struct procStatus    *create_status(status)
  720. struct type_Qmgr_ProcStatus    *status;
  721. {
  722.     struct procStatus    *temp;
  723.  
  724.     temp = (struct procStatus *) malloc(sizeof(*temp));
  725.  
  726.     temp->enabled = status->enabled;
  727.     temp->lastAttempt = convert_time(status->lastAttempt);
  728.     temp->cachedUntil = convert_time(status->cachedUntil);
  729.     temp->lastSuccess = convert_time(status->lastSuccess);
  730.     return temp;
  731. }
  732.  
  733. void    update_status(old, new)
  734. struct procStatus        *old;
  735. struct type_Qmgr_ProcStatus    *new;
  736. {
  737.     time_t    tmp;
  738.     old->enabled = new->enabled;
  739.  
  740.     old->lastAttempt = convert_time(new->lastAttempt);
  741.     
  742.     old->cachedUntil = convert_time(new->cachedUntil);
  743.  
  744.     if ((tmp = convert_time(new->lastSuccess)) != 0)
  745.         old->lastSuccess = tmp;
  746. }
  747.